﻿using System;
using System.Data;
using System.Collections.Generic;
using ElingOA6_Admin_DSJCJ.Model;
namespace ElingOA6_Admin_DSJCJ.BLL
{
    /// <summary>
    /// 上班时间定义
    /// </summary>
    public partial class WorkTime
    {
        /// <summary>
        /// 工作时间定义
        /// </summary>
        private readonly ElingOA6_Admin_DSJCJ.DAL.WorkTime dal = new ElingOA6_Admin_DSJCJ.DAL.WorkTime();
        /// <summary>
        /// 工作时间定义
        /// </summary>
        public WorkTime()
        { }
        #region  BasicMethod
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <param name="fWorkTimeID">编号</param>
        /// <param name="fEntityNo">单位编号</param>
        /// <returns>是否存在该数据</returns>
        public bool Exists(decimal fWorkTimeID, string fEntityNo)
        {
            return dal.Exists(fWorkTimeID, fEntityNo);
        }


        /// <summary>
        /// 获取上下班时间
        /// </summary>
        /// <param name="date">需获取的哪天的上下班时间</param>
        /// <param name="type">上班时间或下班时间</param>
        /// <param name="amorpm">上午或下午</param>
        /// <returns>上下班时间</returns>
        public string GetTime(string date, string type, string amorpm)
        {
            return dal.GetTime(date, type, amorpm);
        }

        /// <summary>
        /// 更具日期获取改天的上下班时间
        /// </summary>
        /// <param name="date">需获取的日期</param>
        /// <returns>实体类</returns>
        public Model.WorkTime GetModelByDate(string date)
        {
            return dal.GetModelByDate(date);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">增加实体类</param>
        /// <returns>是否增加成功</returns>
        public decimal Add(ElingOA6_Admin_DSJCJ.Model.WorkTime model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">更新实体类</param>
        /// <returns>是否更新成功</returns>
        public bool Update(ElingOA6_Admin_DSJCJ.Model.WorkTime model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <param name="fWorkTimeID">编号</param>
        /// <returns>是否删除成功</returns>
        public bool Delete(decimal fWorkTimeID)
        {

            return dal.Delete(fWorkTimeID);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <param name="fWorkTimeID">编号</param>
        /// <param name="fEntityNo">公司编号</param>
        /// <returns>是否删除成功</returns>
        public bool Delete(decimal fWorkTimeID, string fEntityNo)
        {

            return dal.Delete(fWorkTimeID, fEntityNo);
        }
        /// <summary>
        /// 批量删除数据
        /// </summary>
        /// <param name="fWorkTimeIDlist">编号列表以“，”分隔</param>
        /// <returns>是否删除成功</returns>
        public bool DeleteList(string fWorkTimeIDlist)
        {
            return dal.DeleteList(fWorkTimeIDlist);
        }

        /// <summary>
        ///  得到一个对象实体
        /// </summary>
        /// <param name="fWorkTimeID">编号</param>
        /// <returns>实体类</returns>
        public ElingOA6_Admin_DSJCJ.Model.WorkTime GetModel(decimal fWorkTimeID)
        {

            return dal.GetModel(fWorkTimeID);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <param name="strWhere">查询条件</param>
        /// <returns>DataSet对象</returns>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        /// <param name="top">前几行数据</param>
        /// <param name="strWhere">查询条件</param>
        /// <param name="filedOrder">排序方式</param>
        /// <returns>DataSet对象</returns>
        public DataSet GetList(int top, string strWhere, string filedOrder)
        {
            return dal.GetList(top, strWhere, filedOrder);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <param name="strWhere">查询条件</param>
        /// <returns>List对象</returns>
        public List<ElingOA6_Admin_DSJCJ.Model.WorkTime> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }

        /// <summary>
        /// DataSet转换List
        /// </summary>
        /// <param name="dt">DataSet对象</param>
        /// <returns>List对象</returns>
        public List<ElingOA6_Admin_DSJCJ.Model.WorkTime> DataTableToList(DataTable dt)
        {
            List<ElingOA6_Admin_DSJCJ.Model.WorkTime> modelList = new List<ElingOA6_Admin_DSJCJ.Model.WorkTime>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_Admin_DSJCJ.Model.WorkTime model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <param name="strWhere">查询条件</param>
        /// <returns>DataSet对象</returns>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 获取记录总数
        /// </summary>
        /// <param name="strWhere">查询条件</param>
        /// <returns>记录总数</returns>
        public int GetRecordCount(string strWhere)
        {
            return dal.GetRecordCount(strWhere);
        }



        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        /// <param name="tableName">表明</param>
        /// <param name="fields">显示字段</param>
        /// <param name="pageSize">每页多少条数据</param>
        /// <param name="pageIndex">第几页</param>
        /// <param name="strWhere">查询条件</param>
        /// <param name="fOrderFiled">排序字段</param>
        /// <param name="orderType">排序方式</param>
        /// <param name="total">总记录数</param>
        /// <returns>DataSet对象</returns>
        public List<ElingOA6_Admin_DSJCJ.Model.WorkTime> GetWorkTimeListByPage(string tableName, string fields, int pageSize, int pageIndex, string strWhere, string fOrderFiled, int orderType, out int total)
        {
            DataSet ds = dal.GetWorkTimeListByPage(tableName, fields, pageSize, pageIndex, strWhere, fOrderFiled, orderType, out total);
            return DataTableToList(ds.Tables[0]);
        }
     

        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}

